package org.pok.sort;

import java.util.LinkedList;
import java.util.List;

public class Item {

  protected Integer value;

  public static final Item MIN_VALUE = new Item(Integer.MIN_VALUE);

  public Item(Integer value) {
    this.value = value;
  }

  public boolean equals(Item other) {
    return value.equals(other.value);
  }

  public int compareTo(Item other) {
    return value.compareTo(other.value);
  }

  protected void storeInto(Partition partition) {
    partition.addItem(this);
  }
  
  // OK
  public static List<Item> wrap(List<Integer> source) {
	List<Item> result = new LinkedList<Item>();  
	for (Integer current : source) {
      result.add(new Item(current));
    }
	return result;
  }

  // OK
  public static List<Integer> unwrap(List<Item> source) {
	List<Integer> result = new LinkedList<Integer>();  
	for (Item current : source) {
      result.add(current.value);
    }
	return result;
  }

}
